<?php

namespace App\Logging\Processor;

use App\Logging\Service\LogCmdService;
use App\Logging\Service\LogService;
use Monolog\Processor\ProcessorInterface;

class CmdProcessor implements ProcessorInterface
{
    /**
     * Invoke the processor.
     *
     * @param  array  $record
     * @return array
     */
    public function __invoke(array $record)
    {
        // 添加额外的信息到日志记录中
        $record['cmdName'] = LogCmdService::getInstance()->getCmdName();
        $record['cmdClass'] = LogCmdService::getInstance()->getCmdClass();
        $record['traceId'] = LogService::getInstance()->getFinalTraceId();
        $record['datetime'] = date('Y-m-d H:i:s', strtotime($record['datetime']));

        return $record;
    }
}
